// @dart=2.12
import 'package:floor/floor.dart';
import 'package:ls_work/util/ext_utils.dart';

var _format = ['yyyy', '-', 'mm', '-', 'dd'];

var _timeFormat = ['HH',':','nn'];

@entity
class PatrolTaskData {
  PatrolTaskData({
    this.resultStatusName,
    this.taskId,
    this.name,
    this.startDate,
    this.endDate,
    this.pointTotal,
    this.finishedNum,
    this.unfinishedNum,
    this.resultStatus,
    this.status,
    this.remark,
    this.deleteStatus,
    this.branchId,
    this.patrolRange,
    this.isNotice,
    this.id,
    this.createdBy,
    this.createdDate,
    this.updatedBy,
    this.updatedDate,
  });

  PatrolTaskData.fromJson(dynamic json) {
    resultStatusName = json['resultStatusName'];
    taskId = json['taskId'];
    name = json['name'];
    startDate = json['startDate'];
    endDate = json['endDate'];
    pointTotal = json['pointTotal'];
    finishedNum = json['finishedNum'];
    unfinishedNum = json['unfinishedNum'];
    resultStatus = json['resultStatus'];
    status = json['status'];
    remark = json['remark'];
    deleteStatus = json['deleteStatus'];
    branchId = json['branchId'];
    patrolRange = json['patrolRange'];
    isNotice = json['isNotice'];
    id = json['id'];
    createdBy = json['createdBy'];
    createdDate = json['createdDate'];
    updatedBy = json['updatedBy'];
    updatedDate = json['updatedDate'];
    taskDate = startDate?.formatDateStr(format: _format);
  }

  String? resultStatusName;
  int? taskId;
  String? name;
  String? startDate;
  String? endDate;
  int? pointTotal;
  int? finishedNum;
  int? unfinishedNum;
  int? resultStatus;
  int? status;
  String? remark;
  int? deleteStatus;
  int? branchId;
  String? patrolRange;
  int? isNotice;
  @primaryKey
  int? id;
  String? createdBy;
  String? createdDate;
  String? updatedBy;
  String? updatedDate;

  String? taskDate;

  String get timeRange => "${startDate?.formatDateStr(format: _timeFormat)}-${endDate?.formatDateStr(format: _timeFormat)}";


  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['resultStatusName'] = resultStatusName;
    map['taskId'] = taskId;
    map['name'] = name;
    map['startDate'] = startDate;
    map['endDate'] = endDate;
    map['pointTotal'] = pointTotal;
    map['finishedNum'] = finishedNum;
    map['unfinishedNum'] = unfinishedNum;
    map['resultStatus'] = resultStatus;
    map['status'] = status;
    map['remark'] = remark;
    map['deleteStatus'] = deleteStatus;
    map['branchId'] = branchId;
    map['patrolRange'] = patrolRange;
    map['isNotice'] = isNotice;
    map['id'] = id;
    map['createdBy'] = createdBy;
    map['createdDate'] = createdDate;
    map['updatedBy'] = updatedBy;
    map['updatedDate'] = updatedDate;
    return map;
  }
}
